Language Overview Lexical binding
proc Button mkButton(String flip, String flop)
{
Button ret = new Button;
boolean state = true;
ButtonLabel(ret, flop);
proc void flip_proc()
{
if (state)
{ ButtonLabel(ret, flip); state = false; }
else
{ ButtonLabel(ret, flop); state = true; }
}
SetAction(ret, flip_proc);
return (ret);
}
Add(thisApplet, mkButton('to be', 'not to be'));
Add(thisApplet, mkButton('procedural', 'functional'));
Notice that procedures can be nested. Lexical binding means
that the procedures "capture" the values of any free variables
from when the procedure was defined.
All the variables in flip_proc are free, so it
captures them with the values that were present
when flip_proc was defined.
KB Sriram
Comments, bug reports: kbs@sbktech.org
Revised: Sat May 25 02:58:14 1996
URL: http://www.sbktech.org/yas_lex.html